package com.pulsarwebdevelopment.concordance.plugins.android;

import java.util.HashMap;
import java.util.Map;

import com.pulsarwebdevelopment.concordance.plugins.Plugin;
import com.pulsarwebdevelopment.concordance.plugins.PluginScreen;

import android.app.Activity;
import android.content.Intent;

public class LiveSearch implements Plugin {
	
	private int concordanceId;

	public Map<String, Argument> getParameterList() {
		Map<String, Plugin.Argument> args = new HashMap<String, Plugin.Argument>();
		
		args.put("concordance", new Plugin.Argument(SelectionType.ConcordanceList, null, "Concordance to search", null));
		
		return args;
	}

	public String getTitle() {
		return "Live Search";
	}

	public String getDescription() {
		return "This plug-in will allow you to search for any word and will update the search results as you type";
	}

	public void run(Map<String, Argument> args) {
		Activity caller = (Activity) args.get("androidCallingActivity").selectedValue;
		
		this.concordanceId = (Integer) args.get("concordance").selectedValue;
		
    	Intent myIntent = new Intent(caller.getApplicationContext(), LiveSearchActivity.class);
    	myIntent.putExtra(LiveSearchActivity.CONC_ID_KEY_NAME, concordanceId);
    	caller.startActivity(myIntent);
		
	}

	public void plug(PluginScreen screen) {
		// TODO Auto-generated method stub
		
	}

	public void go(Object[] args) {
		// TODO Auto-generated method stub
		
	}

	public boolean requiresCompiledConcordances() {
		return true;
	}
}
